package com.atgouwu.mall.seckill.config;

import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.io.IOException;

/**
 * Redisson分布式锁配置
 */
@Configuration
public class MyRedissonConfig {

    //通过RedissonClient使用Redisson
    @Bean(destroyMethod = "shutdown")
    public RedissonClient redissonClient() throws IOException {
        Config config = new Config(); //创建配置
        config.useSingleServer().setAddress("redis://192.168.77.130:6379");
        RedissonClient redissonClient = Redisson.create(config); //根据Config创建RedissonClient
        return redissonClient;
    }

}
